import request from "@/utils/request";
import fileRequest from "@/utils/request";

const serverUrl = "/pro-api"

// 获取文件列表
export function fileList(data: any) {
    return request({
        url: serverUrl+"/file/tree",
        method: "get",
        params: data,
    })
}

// 新建文件夹
export function newFolder(data: any) {
    return request({
        url: serverUrl+"/file/new_folder",
        method: "post",
        data,
    })
}

// 分片上传文件
export function fileChunk(data: any) {
    return fileRequest({
        url: serverUrl+"/file/chunk",
        method: "post",
        data,
        headers: {
            "Content-Type": "multipart/form-data"
        }
    })
}

// 文件校验
export function fileCheck(data: any) {
    return fileRequest({
        url: serverUrl+"/file/check",
        method: "post",
        data
    })
}

// 上传文件
export function fileUpload(data: any) {
    return fileRequest({
        url: serverUrl+"/file/upload",
        method: "post",
        data
    })
}

// 合并分块文件
export function mergeFile(data: any) {
    return fileRequest({
        url: serverUrl+"/file/merge",
        method: "post",
        data
    })
}

// 预览图片
export function previewImage(data: any) {
    return fileRequest({
        url: serverUrl+"/file/preview/image",
        method: "post",
        data
    })
}

// 删除文件
export function deleteFile(data: any) {
    return fileRequest({
        url: serverUrl+"/file/delete",
        method: "post",
        data
    })
}


// 获取还原站的文件列表
export function getDeleteList() {
    return fileRequest({
        url: serverUrl+"/file/delete/list",
        method: "get"
    })
}


// 还原文件
export function restoreFile(data: any) {
    return fileRequest({
        url: serverUrl+"/file/restore",
        method: "post",
        data: data
    })
}

// 检索文件
export function searchFile(data: any) {
    return fileRequest({
        url: serverUrl+"/file/search",
        method: "post",
        data: data
    })
}


// 下载文件
export function download(data: any) {
    return fileRequest({
        url: serverUrl+"/file/created/download",
        method: "post",
        data
    })
}




